package servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import Bizlogic.CAManager;
import Model.Product;




public class UpdateProduct extends HttpServlet {
	
	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		int num=Integer.parseInt(request.getParameter("productnum"));
		String name=request.getParameter("productname");
		double unitprice=Double.parseDouble(request.getParameter("unitprice"));
		String description=request.getParameter("description");
		String color=request.getParameter("color");
		String dimension=request.getParameter("dimension");
		int minorder=Integer.parseInt(request.getParameter("minorder"));
		int reorderlevel=Integer.parseInt(request.getParameter("reorderlevel"));
		String shelflocation=request.getParameter("shelflocation");
		int instock=Integer.parseInt(request.getParameter("instock"));
		String manufacturer=request.getParameter("manufacturer");
		Product p=new Product();
		p.setColor(color);
		p.setDescription(description);
		p.setDimension(dimension);
		p.setInstock(instock);
		p.setManufacturer(manufacturer);
		p.setMinorder(minorder);
		p.setProductname(name);
		p.setProductnum(num);
		p.setReorderlevel(reorderlevel);
		p.setShelflocation(shelflocation);
		p.setUnitprice(unitprice);
		CAManager caManager=new CAManager();
		caManager.updateProduct(p);
		request.getRequestDispatcher("home.jsp").forward(request, response);
		
	
	}

}
